package com.weasel.weixin.commons.message.builder;

import com.weasel.weixin.commons.message.bean.WeiXinPostCommonXmlAnswerVoiceMessage;

/**
 * Created by Dylan on 2015/10/12.
 */
public class WeixinPostCommonXmlAnswerVoiceMessageBuilder extends AbstractWeixinPostCommonXmlAnswerMessageBuilder<WeixinPostCommonXmlAnswerVoiceMessageBuilder,WeiXinPostCommonXmlAnswerVoiceMessage>{

    public WeixinPostCommonXmlAnswerVoiceMessageBuilder() {
        super(new WeiXinPostCommonXmlAnswerVoiceMessage());
    }

    public WeixinPostXmlAnswerVoiceBodyMessageBuilder addVoice(){

        return new WeixinPostXmlAnswerVoiceBodyMessageBuilder(this);
    }


    public static class WeixinPostXmlAnswerVoiceBodyMessageBuilder{

        private WeixinPostCommonXmlAnswerVoiceMessageBuilder parent = null;

        private WeiXinPostCommonXmlAnswerVoiceMessage.VoiceBody body = new WeiXinPostCommonXmlAnswerVoiceMessage.VoiceBody();

        public WeixinPostXmlAnswerVoiceBodyMessageBuilder(){
        }

        public WeixinPostXmlAnswerVoiceBodyMessageBuilder(WeixinPostCommonXmlAnswerVoiceMessageBuilder _parent){

            this.parent = _parent;
        }

        public WeixinPostXmlAnswerVoiceBodyMessageBuilder mediaId(String mediaId){

            body.setMediaId(mediaId);
            return this;
        }

        public WeixinPostCommonXmlAnswerVoiceMessageBuilder end(){
            if(null == parent){
                throw new RuntimeException("请调用带参的构造方法，并传递WeixinPostCommonXmlAnswerImageMessageBuilder参数，否则请调用build方法");
            }
            ((WeiXinPostCommonXmlAnswerVoiceMessage)parent.message).setVoice(build());
            return parent;
        }


        public WeiXinPostCommonXmlAnswerVoiceMessage.VoiceBody build(){
            return body;
        }

    }
}
